<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Leaving Document</title>

<script type="text/javascript">

function checkUrl(href) {
	var leaving = ((href.indexOf("://") > -1) || (href.indexOf("www.") > -1));
	return leaving;
// add in more things to include in the line above as you see fit
}
function pop(hrefPar) {
		var toURL = window.location.href;
		alert("hehe --\>" + hrefPar);//window.open("demo.html");
}

//window.onunload = pop;
function relink() {
	var e11 = document.getElementsByTagName("a");	
	//alert(e11.length);
	for(var i=0;i<e11.length;i++) {
		e11[i].onclick = "pop(this.href)";
		if (checkUrl(e11[i].href)){
			var home = (""+document.URL).substring(0,12);
			if (e11[i].href.indexOf(home) == 0) continue;
			//alert("hehe ["+home+"]! \n" +e11[i].href + "\n  --\>  \n" + document.URL);
			e11[i].href =  window.location.href;
			
		}
	}
}
//window.onload = relink();
</script>
</head>
<body onload="return relink()">
<br>
<a href="http://www.giigke.com/">Click here and you'll see a popup window</a>
<br>
<a href="internal.htm">Click here and you won't</a>
<br>
<a href="www.habrle.com/">Click here and you'll see a popup window</a>
<br>
<a href="internal.htm">Click here and you won't</a>
<br>
<a href="https://www.ibm.com/">Click here and you'll see a popup window</a>
<br>
<a href="cia.htm">Click here and you won't</a>
</body>
</html>